package com.ymtms.statisticalform.dao;

import com.ymtms.statisticalform.pojo.EmpBusiness;
import org.apache.ibatis.annotations.Select;

public interface EmpBusinessMapper {

    /**
     * 单据分发 单据分发表
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM bill_distribute WHERE flag=0 AND release_person=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(receive_bill_time) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(receive_bill_time) = #{month}\n" +
            "    </if> </script>")
    int selectReleaseBillNumber(String empName,String year,String month);

    /**
     * 货运单主表填写 货运单主表
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM goodsbill_master WHERE flag=0 AND write_bill_person=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(write_date) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(write_date) = #{month}\n" +
            "    </if> </script>")
    int writeGoodsBillMasterNumber(String empName, String year, String month);

    /**
     * 运单表  承运人     ？？？司机？？？
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM waybill WHERE flag=0 AND receive_goods_customer=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(end_carry_time) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(end_carry_time) = #{month}\n" +
            "    </if> </script>")
    int driverWayNumber(String empName, String year, String month);

    /**
     * 司机表 司机
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM driver_information WHERE flag=0 AND driver_name=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(receive_bill_time) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(receive_bill_time) = #{month}\n" +
            "    </if> </script>")
    int driverNumber(String empName, String year, String month);

    /**
     * 投诉表 投诉处理
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM complaint_information WHERE flag=0 AND deal_person=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(deal_date) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(deal_date) = #{month}\n" +
            "    </if> </script>")
    int complaintDealNumber(String empName, String year, String month);

    /**
     * 回告信息
     * @param empName
     * @param year
     * @param month
     * @return
     */
    @Select("<script> SELECT COUNT(flag) FROM callback_information WHERE flag=0 AND writer=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(finally_dial_time) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(finally_dial_time) = #{month}\n" +
            "    </if> </script>")
    int callBackWriterNumber(String empName, String year, String month);











    @Select("<script> SELECT COUNT(flag) FROM bill_distribute WHERE flag=0 AND release_person=#{empName}\n" +
            "    <if test=\"year !=null and year !=''\">\n" +
            "      and YEAR(receive_bill_time) = #{year}\n" +
            "    </if>\n" +
            "    <if test=\"month !=null and month !=''\">\n" +
            "      and MONTH(receive_bill_time) = #{month}\n" +
            "    </if> </script>")
    EmpBusiness getBusiness(String empName, String year, String month);
}
